#!/usr/bin/env python
#-*-coding: utf-8 -*-
# author: weiyf    data:2015/05/16

import bin.setpath
def main():
    from sys import argv,stdout

    def usage():
        stdout.write('Usage: ./scriptname.py filename\n')

    ORF=['\t\t\033[32m[ OK ]\033[0m\n','\t\t\033[31m[ FAIL ]\033[0m\n']

    try:
        iprange = open(argv[1]).readlines()
        stdout.write('Reading file ...')
        length = len(iprange)
        stdout.write(ORF[0])
        stdout.write('Total: '+str(length)+' lines\n')
    except:
        stdout.write('\033[31mError!!! please check\033[0m\n')
        usage()
        exit(1)

    
    stdout.write('Check network ...')
    if netcheck():
        stdout.write(ORF[0])
    else:
        stdout.write(ORF[1])
        exit(3)

main()
